#! /usr/bin/python
# -*- coding: cp1250 -*-
#sys.path.append(r'C:\AFT\.pylib')

# customized version : vp-20080929

import string, sys, glob, re
import pepe.p_txt.bigtxt as bt

#strip blank spaces around delimiters of csv files.

lino = 0
flino = 0
of = open('gl.da_', 'w')

inp_delimiter = '^'
out_delimiter = '^'

for filename in glob.glob('*.dat'):

    for line in bt.lines(filename):

        line = re.sub('\n', '', line)
    
        lino += 1
        flino += 1

        if lino == 1 : of.write(line + '\n')
    
        if flino > 2 :
            cols = string.split(line, inp_delimiter)
            bare_cols = [string.strip(c) for c in cols]
            of.write(string.join(bare_cols, out_delimiter)+'\n')

    flino = 0

of.close()


